<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<link rel="stylesheet" href="../../css/animate.css">
		<link rel="stylesheet" href="../../iconfont/iconfont.css">
		<link rel="stylesheet" href="../../css/mescroll.css">
		<link rel="stylesheet" href="../../css/gloab.css">
		<title>海报展示</title>
	</head>
	<body>
		<div id="app">
			<div id="public-header">
				<div id="statusbar"></div>
				<header class="public-header">
					<div class="public-header-lf iconfont icon-fanhui" @click="javascript:api.closeWin();"></div>
					<div class="public-header-title">海报展示</div>
				</header>
			</div>
			<div style="height:50%;width:100%;overflow:hidden;display:block;" id="img1">
				<img :src="url" alt="">
			</div>
			<div class="guanggao-details-page flex">
				<div style="width:20%;height:30px;line-height:30px;color:#fff;border-radius:0.5rem;background:#4293f2;text-align:center;margin:auto;"
				 @click="savePicture">保存</div>
			</div>
			<div class="guanggao-details-share flex wrap auto" style="margin-top:0.46rem;">
				<div class="guanggao-details-share-lf F2"></div>
				<div class="guanggao-details-share-text F1">分享至</div>
				<div class="guanggao-details-share-lf F2"></div>
			</div>
			<div class="guanggao-details-page auto" style="text-align:center;margin-top:0.2rem;padding-bottom:0.5rem;font-size:0.2rem;">
				<div class="guanggao-details-page-son" style="display:inline-block;margin-right:0.3rem;color:#404040;" @click="shares">
					<img src="../../image/personal/icon1.png" alt="">
					<span>微信</span>
				</div>
				<div class="guanggao-details-page-son" style="display:inline-block;color:#404040;" @click="share">
					<img src="../../image/personal/icon2.png" alt="">
					<span>朋友圈</span>
				</div>
			</div>
		</div>
		<div class="public-progress" style="z-index:9;">
			<img src="../../icon/icon150x150.png" alt="" class="animated infinite flash" style="width:200px;height:200px;display:block;margin:200px auto;">
		</div>
	</body>
	<script src="../../script/api.js"></script>
	<script src="../../script/jquery.js"></script>
	<script src="../../script/mescroll.js"></script>
	<script src="../../script/vue.js"></script>
	<script src="../../script/app.js"></script>
	<script src="../../script/fastclick.js"></script>
	<script src="../../script/jsencrypt.js"></script>
	<script>
		var vm;
		var mescroll;
		var mySwiper;
		apiready = function() {
			api.removeLaunchView();
			setBar("statusbar");
			setFont(750);
			startVue();
			$(".public-progress").fadeOut(1000);
			setTimeout(function() {
				$(".public-progress").css({
					"display": "none"
				});
			}, 1000);
		}

		function startVue() {
			vm = new Vue({
				el: "#app",
				data: {
					url: api.pageParam.url,
				},
				created: function() {},
				methods: {
					//获取分享赠送积分
					getIntegral: function() {
						api.ajax({
							url: apiUrl + 'api/home/getIntegral',
							method: 'post',
							data: {
								values: {
									uid: post_en($api.getStorage('uid')),
								},
							}
						}, function(ret, err) {
							if (ret.status) {
								alert(ret.msg);
							} else {
								alert(ret.msg);
							}
						});
					},
					//分享到好友
					shares: function() {
						// alert('开发中......');return;
						var wxPlus = api.require('wxPlus');
						wxPlus.isInstalled(function(ret, err) {
							if (ret.installed) {
								wxPlus.shareImage({
									apiKey: '',
									scene: 'session',
									thumb: 'widget://icon/logo.jpg',
									contentUrl: api.pageParam.url,
								}, function(ret, err) {
									if (ret.status) {
										vm.getIntegral();
									} else {
										alert(err.code);
									}
								});
							} else {
								alert('当前设备未安装微信客户端');
							}
						});
					},
					//分享朋友圈
					share: function() {
						// alert('开发中......');return;
						var wxPlus = api.require('wxPlus');
						wxPlus.isInstalled(function(ret, err) {
							if (ret.installed) {
								var wxPlus = api.require('wxPlus');
								wxPlus.shareImage({
									apiKey: '',
									scene: 'timeline',
									thumb: 'widget://icon/logo.jpg',
									contentUrl: api.pageParam.url,
								}, function(ret, err) {
									if (ret.status) {
										alert('分享成功');
									} else {
										alert(err.code);
									}
								});
							} else {
								alert('当前设备未安装微信客户端');
							}
						});
					},
					save: function() {
						var result = hasPermission('storage'); //权限检测
						var text = '"趣引流"需要使用相册功能,请设置本地存储权限,点击确定前往设置本地存储权限,点击取消拒绝';
						requestPermission(text, 'storage', result, function(bool) {
							if (bool) {
								api.saveMediaToAlbum({
									path: 'http://ysmc.xiaoxiongkeji.cn/static/poster/2/1-1a5775b6ac664cfef7b2347048db233d3.jpg',
									groupName: 'fs://',
								}, function(ret, err) {
									console.log(ret)
									if (ret && ret.status) {
										alert('保存成功');
									} else {
										alert('保存失败');
									}
								});
							} else {
								msg("获取本地储存权限失败!无法打开相册");
							}
						})
					},
					savePicture: function(url) {
						var timestamp = new Date().getTime()
						api.download({
							url: api.pageParam.url,
							savePath: 'fs://test' + timestamp + '.jpeg',
							report: true,
							cache: true,
							allowResume: true
						}, function(ret, err) {
							if (ret.state == 1) {
								api.saveMediaToAlbum({
									path: 'fs://test' + timestamp + '.jpeg',
									groupName: '趣引流',
								}, function(res, err) {
									if (res && res.status) {
										alert('保存成功');
									} else {
										alert('保存失败');
									}
								});
							} else {

							}
						});
					}
				}
			})
		}
	</script>
</html>
